package yanglib.application.metadata;

import yanglib.application.metadata.client.MetadataClient;
import yanglib.application.metadata.server.MetadataServer;

import java.nio.ByteBuffer;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * User: user
 * Date: 9/9/14
 * Time: 9:18 PM
 * To change this template use File | Settings | File Templates.
 */
public class TestPerformance {

    public static void main(String[] args) throws Exception{
        MetadataServer server1 = new MetadataServer(2, "D:\\project-of-yang\\library\\config.xml", "D:\\project-of-yang\\library");
        MetadataServer server2 = new MetadataServer(3, "D:\\project-of-yang\\library\\config.xml", "D:\\project-of-yang\\library");
        MetadataClient client = new MetadataClient(0,  "D:\\project-of-yang\\library\\config.xml");
        Random r = new Random();
        long count = 1000000;
        long startTime = System.currentTimeMillis();
        for(long i=0; i<count; i++){
            byte[] keyBytes = new byte[8];
            byte[] valueBytes = new byte[4096];
            r.nextBytes(keyBytes);
            r.nextBytes(valueBytes);
            client.put(keyBytes, valueBytes);
        }
        System.out.println("throughput = " + count * 1000L / (System.currentTimeMillis() - startTime));
        System.exit(0);
        //Thread.sleep(60000);
        //MetadataServer server2 = new MetadataServer(3,  "D:\\project-of-yang\\library\\config.xml");
    }
}
